package com.daikun.common.exception;

import com.daikun.common.iface.BaseResultIface;
import lombok.Getter;

/**
 * 自定义业务异常
 * 此异常没有堆栈信息，抛出的异常对象 {@link BaseResultIface} 必须唯一
 * 方便直接从日志中进行问题定位，无需代码排查
 * @author earl created 2025-07-03
 * @version init 0.0.1
 */
@Getter
public class BizException extends RuntimeException {

    private final Object data;
    private final BaseResultIface item;

    public BizException(BaseResultIface item) {
        this(item, item.getMsg());
    }

    public BizException(BaseResultIface item, String msg) {
        super(msg);
        this.data = null;
        this.item = item;
    }

    public BizException(BaseResultIface item, Object data) {
        this(item, item.getMsg(), data);
    }

    public BizException(BaseResultIface item, String msg, Object data) {
        super(msg);
        this.data = data;
        this.item = item;
    }

    @Override
    public synchronized Throwable fillInStackTrace() {
        return this;
    }

}
